from datetime import datetime

from django.contrib.auth.models import User


def delete_inactive_users(since=60 * 60 * 6):
    for user in User.objects.filter(is_active=False):
        delta = datetime.now() - user.date_joined
        if delta.seconds > since:
            user.delete()
    return True
